Object.defineProperty(exports, "__esModule", {
    value: !0
}), exports.checkImgIsValid = function(a) {
    var s = 1 < arguments.length && void 0 !== arguments[1] && arguments[1], i = !(2 < arguments.length && void 0 !== arguments[2]) || arguments[2], u = e.default.url("entry/wxapp/yx", {
        save: s,
        safe: i,
        m: t.default.m || "one_wifi",
        yx: "Service.checkImageValid"
    });
    return new Promise(function(e, t) {
        wx.uploadFile({
            url: u,
            name: "file",
            filePath: a,
            header: {
                "content-type": "multipart/form-data"
            },
            success: function(a) {
                0 === (a = JSON.parse(a.data)).errcode ? e(a.data) : t(a);
            },
            fail: function(e) {
                console.error("checkImgUploadIsValid ERROR:", e), t(e);
            }
        });
    });
}, exports.batchUploadFile = function a(s, i, u) {
    var l, r, c, n, o, m, f = e.default.url("entry/wxapp/yx", {
        m: t.default.m || "one_wifi",
        yx: "Service.saveFile"
    });
    s.imgPaths && s.imgPaths.length ? (l = s.imgPaths.length, r = s.subscript || 0, 
    c = s.successNum || 0, n = s.failNum || 0, o = s.resultData || [], m = s.uploadFileType || "image", 
    function(e) {
        return /wxfile/.test(e) || /http(s?):\/\/tmp\//.test(e);
    }(s.imgPaths[r]) ? wx.uploadFile({
        url: f,
        filePath: s.imgPaths[r],
        name: "file",
        params: {
            type: m
        },
        headers: {
            "Content-Type": "multipart/form-data"
        },
        success: function(e) {
            200 == e.statusCode ? (e = JSON.parse(e.data), c++, o.push(e.data.url)) : n++;
        },
        fail: function(e) {
            console.log("uploadFile ERROR: ", e), n++;
        },
        complete: function() {
            l <= ++r ? i({
                imgPaths: o,
                successNum: c,
                failNum: n
            }) : (s.subscript = r, s.successNum = c, s.failNum = n, s.resultData = o, a(s, i));
        }
    }) : (c++, o.push(s.imgPaths[r]), l <= ++r ? i({
        imgPaths: o,
        successNum: c,
        failNum: n
    }) : (s.subscript = r, s.successNum = c, s.failNum = n, s.resultData = o, a(s, i)))) : i({
        imgPaths: []
    });
};

a(require("../utils/request"));

var e = a(require("../libs/w7/index")), t = a(require("../siteinfo"));

function a(e) {
    return e && e.__esModule ? e : {
        default: e
    };
}